package com.ssy.lingxi.platform.manage.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.request.content.CollectRequest;
import com.ssy.lingxi.platform.manage.model.request.content.InformationListReq;
import com.ssy.lingxi.platform.manage.model.response.InformationDetailResp;
import com.ssy.lingxi.platform.manage.model.response.InformationListResp;
import com.ssy.lingxi.platform.manage.service.mobile.IInformationMobileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu mobile - 资讯
 * @author fhj
 * @version 2.0.0
 * @date 2021/08/31
 */
@Api(tags = "mobile - 资讯")
@RestController
@RequestMapping("/manage/mobile/informationMobile")
public class InformationMobileController extends BaseController {

    @Resource
    private IInformationMobileService informationMobileService;

    @ApiOperation(value = "列表")
    @GetMapping(value = "/list")
    public Wrapper<PageData<InformationListResp>> list(@Valid InformationListReq req) {
        return informationMobileService.list(req);
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/detail")
    public Wrapper<InformationDetailResp> detail(@Valid CommonIdRequest request) {
        return informationMobileService.detail(request, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "收藏/取消收藏")
    @PostMapping(value = "/collect")
    public Wrapper<Void> collect(@RequestBody @Validated CollectRequest request) {
        return informationMobileService.collect(request, getSysUser());
    }

    @ApiOperation(value = "收藏列表")
    @GetMapping(value = "/collectList")
    public Wrapper<PageData<InformationListResp>> collectList(@Valid PageVO request) {
        return informationMobileService.collectList(request, getSysUser());
    }

    @ApiOperation(value = "历史浏览")
    @GetMapping(value = "/history")
    public Wrapper<List<InformationListResp>> history() {
        return informationMobileService.history(getSysUser());
    }
}
